# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Patrick Palka <patrick@parcs.ath.cx>
# Contributor: Loui Chang <louipc.ist at gmail com>
# Contributor: Andreas Baumann <abaumann at yahoo dot com>

pkgname=cgit-aurweb
pkgver=1.2.3
_commit='cc08c9ff936a890206bc2f7560acb44147af9bb8'
pkgrel=3
pkgdesc='A web interface for git written in plain C (aurweb branch)'
arch=('loong64' 'x86_64')
url='https://git.zx2c4.com/cgit/'
license=('GPL2')
depends=('openssl' 'luajit')
makedepends=('git' 'zlib' 'curl' 'asciidoc')
optdepends=('groff: about page using man page syntax'
	    'python-pygments: syntax highlighting support'
	    'python-docutils: about page formatted with reStructuredText'
	    'python-markdown: about page formatted with markdown'
	    'gzip: gzip compressed snapshots'
	    'bzip2: bzip2 compressed snapshots'
	    'lzip: lzip compressed snapshots'
	    'xz: xz compressed snapshots'
	    'zstd: zstd compressed snapshots'
	    'mime-types: serve file with correct content-type header')
install=cgit.install
source=("$pkgname::git+https://gitlab.archlinux.org/archlinux/cgit.git#commit=${_commit}")
sha256sums=('SKIP')

prepare() {
	cd "$pkgname"

	git submodule init
	git submodule update
}

build() {
	cd "$pkgname"

	make
	make doc-man
}

package() {
	cd "$pkgname"
	
	make CGIT_SCRIPT_PATH="/usr/share/webapps/$pkgname" DESTDIR="$pkgdir" prefix=/usr filterdir="/usr/lib/$pkgname/filters" install
	
	install -vd "$pkgdir/var/cache/$pkgname"
	mkdir -p "$pkgdir/usr/lib/$pkgname"
	mv "$pkgdir/usr/share/webapps/$pkgname/cgit.cgi" "$pkgdir/usr/lib/$pkgname"
	ln -sf ../../../lib/$pkgname/cgit.cgi "$pkgdir/usr/share/webapps/$pkgname/cgit.cgi"
}
